<template>
	<view class="container">
		<view class="panel-header padding-top solid-bottom">
			<view class="g-goBack" @click="$common.toBack()">
				<view class="cuIcon-back"></view>
			</view>
			<view class="text-cut">个人钱包</view>
		</view>
		<view class="bg-white margin-top-sm margin-left margin-right padding-sm radius">
			<view class="flex justify-between solid-bottom padding-bottom-xs">
				<view class="text-bold">钱包信息</view>
			</view>
			<view class="flex">
				<view class="flex-sub text-center">
					<view class="text-sm margin-top-sm">钱包余额</view>
					<view class="text-lg margin-top-sm">{{walletInfo.money}}</view>
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub text-center">
					<view class="text-sm margin-top-sm">今年收益金额</view>
					<view class="text-lg margin-top-sm">{{walletInfo.yearIncomeMoney}}</view>
				</view>
				<view class="flex-sub text-center">
					<view class="text-sm margin-top-sm">已提现金额</view>
					<view class="text-lg margin-top-sm">{{walletInfo.totalWithdrawalMoney}}</view>
				</view>
			</view>
		</view>
		<view class="bg-white margin-top-sm margin-left margin-right padding-sm radius" v-if="walletInfo.relationWalletMoney">
			<view class="flex justify-between solid-bottom padding-bottom-xs">
				<view class="text-bold">当前账号钱包</view>
			</view>
			<view class="flex">
				<view class="flex-sub text-center">
					<view class="text-sm margin-top-sm">钱包余额</view>
					<view class="text-lg margin-top-sm">{{walletInfo.relationWalletMoney}}</view>
				</view>
				<view class="flex-sub text-center" v-if="userInfo.roleType == 1">
					<view class="text-sm margin-top-sm">已提现金额</view>
					<view class="text-lg margin-top-sm">{{walletInfo.relationWalletWithdrawnMoney}}</view>
				</view>
				<view class="flex-sub text-center" v-else>
					<view class="text-sm margin-top-sm">已转出金额</view>
					<view class="text-lg margin-top-sm">{{walletInfo.relationWalletWithdrawnMoney}}</view>
				</view>
			</view>
		</view>
		<view class="cu-card article" v-for="(item,index) in walletInfo.items" :key="index">
			<view class="cu-item">
				<view class="title">
					<view class="text-cut text-orange">收款账号：{{item.accountGroupName}}</view>
				</view>
				<view class="content justify-around">
					<view>余额<text class="text-price text-red margin-left-sm">{{item.money}}</text></view>
					<view>冻结<text class="text-price text-red margin-left-sm">{{item.freezeMoney}}</text></view>
					<view>可提现<text class="text-price text-red margin-left-sm">{{item.withdrawalMoney}}</text></view>
				</view>
				<view class="flex align-end justify-end padding-right padding-top">
					<button class="cu-btn bg-orange round sm" @click="btnCashApply(index)">立刻提现</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:this.$store.getters.GET_userInfo || {},
				walletInfo:{},
				modalName:null
			}
		},
		onLoad() {
			this._loadMyWalletInfo()
		},
		methods: {
			//获取我的钱包信息
			_loadMyWalletInfo:function(){
				uni.showLoading({
					title:'加载中..'
				})
				const _self = this;
				const api = this.$request;
				api.post(api.url.myWalletInfo,{},res=>{
					uni.hideLoading();
					console.log(res);
					if(res.code == 200){
						_self.walletInfo = res.body;
					}else if(res.msg){
						uni.showModal({
							content:res.msg,
							showCancel:false
						})
					}else {
						uni.showToast({
							title:'获取钱包失败',
							icon:'error'
						})
					}
				})
			},
			btnCashApply(index){
				let item = this.walletInfo.items[index];
				let way = 1;	//默认微信提现
				if(item.wxBindType == 0){
					way = 3;	//使用二维码提现
				}
				uni.navigateTo({
					url:'./apply?id=' + item.accountGroupId + '&way='+way
				})
			}
		}
	}
</script>

<style lang="less">

</style>
